package com.ethan.minimalist.ui.mine.withdraw

import android.app.Activity
import android.content.Intent
import com.cxz.kotlin.baselibs.base.BaseActivity
import com.cxz.kotlin.baselibs.ext.setSingleClickListener
import com.cxz.kotlin.baselibs.ext.showToast
import com.ethan.minimalist.R
import com.ethan.minimalist.bean.UserBean
import com.ethan.minimalist.constant.Constant
import com.google.gson.Gson
import com.gyf.immersionbar.ImmersionBar
import com.tencent.mmkv.MMKV
import kotlinx.android.synthetic.main.activity_wallet_first_step.*

/**
 * @ClassName:      WithdrawFirstStepActivity
 * @Description:
 * @Author:         ethanWu
 * @CreateDate:     2020/3/19 9:55
 */
open class WalletFirstStepActivity : BaseActivity() {

    private var mUser:UserBean ?= null

    override fun attachLayoutRes(): Int {
        return R.layout.activity_wallet_first_step
    }

    override fun initView() {
        ImmersionBar.with(this@WalletFirstStepActivity)
            .statusBarView(top_view)
            .statusBarDarkFont(true, 0.2f)
            .init()
    }

    override fun initData() {
        super.initData()

        mUser = Gson().fromJson(MMKV.defaultMMKV().decodeString(Constant.USER), UserBean::class.java)
        tv_yuan.text = "${mUser?.balance}元"
        tv_withdraw.setSingleClickListener {
            startActivityForResult(Intent(this@WalletFirstStepActivity, WalletSecStepActivity::class.java),0x10)
        }

        ll_qq.setSingleClickListener {
            showMsg()
        }

        ll_wechat.setSingleClickListener {
            showMsg()
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if(requestCode == 0x10 && resultCode == Activity.RESULT_OK) {
            setResult(Activity.RESULT_OK)
            finish()
        }
    }

    private fun showMsg() {
        showToast("请升级版本")
    }

    override fun start() {
    }
}